package com.codegenerate.demo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.time.LocalDateTime;


@TableName(value ="g_field")
public class GField implements Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    private long id;









    /**
     *
     */
    @TableField(value = "filed_name")
    private String filedName;




    /**
     *
     */
    @TableField(value = "filed_name_chinese")
    private String filedNameChinese;




    /**
     *
     */
    @TableField(value = "filed_type")
    private String filedType;




    /**
     *
     */
    @TableField(value = "g_table_id")
    private long gTableId;


    public long getgTableId() {
        return gTableId;
    }

    public void setgTableId(long gTableId) {
        this.gTableId = gTableId;
    }

    /**
     *
     */
    @TableField(value = "del_state")
    private int delState;









    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

    public String getFiledName() {
        return filedName;
    }
    public void setFiledName(String filedName) {
        this.filedName = filedName;
    }

    public String getFiledNameChinese() {
        return filedNameChinese;
    }
    public void setFiledNameChinese(String filedNameChinese) {
        this.filedNameChinese = filedNameChinese;
    }

    public String getFiledType() {
        return filedType;
    }
    public void setFiledType(String filedType) {
        this.filedType = filedType;
    }



    public int getDelState() {
        return delState;
    }
    public void setDelState(int delState) {
        this.delState = delState;
    }




    /**
     * build
     */
    public static GField build(){
        GField tempEntity = new GField();
        return tempEntity;
    }

    /**
     * build
     */
    public  static void setDefaultValue(GField temp){

        if(temp.getId()<=0){
            temp.setId(0);
        }

        if(StringUtils.isEmpty(temp.getFiledName())){
            temp.setFiledName("");
        }

        if(StringUtils.isEmpty(temp.getFiledNameChinese())){
            temp.setFiledNameChinese("");
        }

        if(StringUtils.isEmpty(temp.getFiledType())){
            temp.setFiledType("");
        }

        if(temp.getgTableId()<=0){
            temp.setgTableId(0);
        }

        if(temp.getDelState()<=0){
            temp.setDelState(1);
        }



    }

    @JsonIgnore
    public LambdaQueryWrapper<GField> getQueryAll() {
        var  query = new QueryWrapper<GField>().lambda();

        if(this.id>0){
            query.eq(GField::getId, this.id);
        }

        if(!StringUtils.isEmpty(this.filedName)){
            query.eq(GField::getFiledName, this.filedName);
        }

        if(!StringUtils.isEmpty(this.filedNameChinese)){
            query.eq(GField::getFiledNameChinese, this.filedNameChinese);
        }

        if(!StringUtils.isEmpty(this.filedType)){
            query.eq(GField::getFiledType, this.filedType);
        }

        if(this.gTableId>0){
            query.eq(GField::getgTableId, this.gTableId);
        }

        if(this.delState>0){
            query.eq(GField::getDelState, this.delState);
        }



        return  query;

    }

    @JsonIgnore
    public static LambdaQueryWrapper<GField> getQuery(){
        var query = new QueryWrapper<GField>().lambda();
        return query;
    }


    @JsonIgnore
    public LambdaUpdateWrapper<GField> getUpdateWrapper() {
        var  updateWrapper = new UpdateWrapper<GField>().lambda();

        if(this.id>0){

            updateWrapper.eq(GField::getId, this.id);

        }

        if(!StringUtils.isEmpty(this.filedName)){

            updateWrapper.set(GField::getFiledName, this.filedName);

        }

        if(!StringUtils.isEmpty(this.filedNameChinese)){

            updateWrapper.set(GField::getFiledNameChinese, this.filedNameChinese);

        }

        if(!StringUtils.isEmpty(this.filedType)){

            updateWrapper.set(GField::getFiledType, this.filedType);

        }

        if(this.gTableId>0){

            updateWrapper.set(GField::getgTableId, this.gTableId);

        }

        if(this.delState>0){

            updateWrapper.set(GField::getDelState, this.delState);

        }



        return updateWrapper;
    }

}


